#include "stdafx.h"
#include <iostream>
#include "rsa.h"
#include "InfInt.h"

InfInt vector2InfInt(const vector_int& v)
{
	InfInt inf(0);
	InfInt p(0x100000000LL);
	for (int i = v.size() - 1; i >= 0; i--)
	{
		inf = inf * p;
		inf += v[i];
	}
	return inf;
}

void verify_multi(const vector_int& l, const vector_int& r, const vector_int& ret)
{
	InfInt il = vector2InfInt(l);
	InfInt ir = vector2InfInt(r);
	InfInt iret = vector2InfInt(ret);
	InfInt result = il * ir;
	if (iret != result)
	{
		cout << "Multi verify failed:" << endl;
		cout << hex << il << " * " << ir << " = " << endl;
		cout << hex << result << endl;
		cout << hex << iret << endl;
		assert(0);
	}
}

void verify_mod(const vector_int& l, const vector_int& r, const vector_int& mod, const vector_int& div)
{
	InfInt il = vector2InfInt(l);
	InfInt ir = vector2InfInt(r);
	InfInt imod = vector2InfInt(mod);
	InfInt idiv = vector2InfInt(div);
	assert(imod == (il % ir));
	assert(idiv == (il / ir));
}
